package com.ruoyi.web.controller.community.integral;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.community.domain.IntApply;
import com.ruoyi.community.service.IIntApplyService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 修改设置申请Controller
 * 
 * @author ruoyi
 * @date 2021-08-23
 */
@RestController
@RequestMapping("/integral/apply")
public class IntApplyController extends BaseController
{
    @Autowired
    private IIntApplyService intApplyService;

    /**
     * 查询修改设置申请列表
     */
    @PreAuthorize("@ss.hasPermi('integral:apply:list')")
    @GetMapping("/list")
    public TableDataInfo list(IntApply intApply)
    {
        startPage();
        List<IntApply> list = intApplyService.selectIntApplyList(intApply);
        return getDataTable(list);
    }

    /**
     * 同意申请
     */
    @PutMapping("/agree")
    public AjaxResult agreeApply(@RequestBody IntApply apply) {
        return toAjax(intApplyService.agreeApply(apply));
    }

    /**
     * 拒绝申请
     */

    @DeleteMapping("/{id}")
    public AjaxResult rejectApply(@PathVariable Long id)
    {
        return toAjax(intApplyService.deleteIntApplyById(id));
    }

    /**
     * 导出修改设置申请列表
     */
    @PreAuthorize("@ss.hasPermi('integral:apply:export')")
    @Log(title = "修改设置申请", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(IntApply intApply)
    {
        List<IntApply> list = intApplyService.selectIntApplyList(intApply);
        ExcelUtil<IntApply> util = new ExcelUtil<IntApply>(IntApply.class);
        return util.exportExcel(list, "修改设置申请数据");
    }

    /**
     * 获取修改设置申请详细信息
     */
    @PreAuthorize("@ss.hasPermi('integral:apply:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(intApplyService.selectIntApplyById(id));
    }

    /**
     * 新增修改设置申请
     */
    @PreAuthorize("@ss.hasPermi('integral:apply:add')")
    @Log(title = "修改设置申请", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody IntApply intApply)
    {
        return toAjax(intApplyService.insertIntApply(intApply));
    }

    /**
     * 修改修改设置申请
     */
    @PreAuthorize("@ss.hasPermi('integral:apply:edit')")
    @Log(title = "修改设置申请", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody IntApply intApply)
    {
        return toAjax(intApplyService.updateIntApply(intApply));
    }

    /**
     * 删除修改设置申请
     */
    @PreAuthorize("@ss.hasPermi('integral:apply:remove')")
    @Log(title = "修改设置申请", businessType = BusinessType.DELETE)
	@DeleteMapping("/more/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(intApplyService.deleteIntApplyByIds(ids));
    }
}
